package com.feituan.wx.controller;

import com.feituan.core.persistence.service.IUserCouponService;
import com.feituan.core.pojo.request.UserCouponQuery;
import com.feituan.core.pojo.request.UserCouponSendReq;
import com.feituan.core.pojo.response.Response;
import com.feituan.core.pojo.response.UserCouponList;
import com.feituan.core.pojo.response.page.PageData;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("userCoupon")
public class UserCouponController {

    @Resource
    private IUserCouponService userCouponService;

    /**
     * 发送优惠券
     * @param userCouponSendReq
     * @return
     */
    @PostMapping("/assign_coupon")
    @ApiOperation("发放优惠券")
    public Response<Boolean> save(@RequestBody UserCouponSendReq userCouponSendReq) {
        userCouponService.sendCoupon(userCouponSendReq);
        return Response.success();
    }


    /**
     * 用户优惠券列表
     * @param userCouponQuery
     * @return
     */
    @PostMapping("/getCouponByUserId")
    public Response<PageData<UserCouponList>> selectCouponByUserId(UserCouponQuery userCouponQuery) {
        PageData<UserCouponList> userCouponListInfoPageData = userCouponService.selectCouponByUserId(userCouponQuery);
        return Response.success(userCouponListInfoPageData);
    }


}
